package com.controller;


import com.entity.Contact;
import com.entity.News;
import com.service.ContactService;
import com.util.StatusCode;
import com.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


@Controller
public class ContactController {


    @Autowired
    private ContactService contactService;

    @ResponseBody
    @PostMapping("/contact/add")
    public void insertCon(@RequestParam("name") String name,
                          @RequestParam("email") String email,
                          @RequestParam("message") String message,
                          Contact contact){
        contact.setName(name);
        contact.setEmail(email);
        contact.setMessage(message);
        contactService.insertContact(contact);
    }


    @ResponseBody
    @GetMapping("/contact/look")
    public ResultVo que(){
        List<Contact> newsList = (List<Contact>) contactService.que();
        return new ResultVo(true, StatusCode.OK,"查询成功",newsList);
    }

    @GetMapping("/contact/kan")
    public String kan(){
        return "/admin/conList";
    }


}
